#include <stdio.h>
#include <stdbool.h>

int main(){
    int total_count = 0, word_count = 0;
    char ch;
    bool new_word_flag = true;

    printf("Enter a sentence: ");

    while ((ch = getchar()) != '\n') {
        if (ch != ' ') {
            total_count++;

            if (new_word_flag) {
                word_count++;
                new_word_flag = false;
            }
        } else {
            new_word_flag = true;
        }
    }

    printf("Average word length: %f\n", (float) total_count / word_count);

    return 0;
}
